function saveAxes(haxes, figfile)
% FUNCTION SAVEAXES(HAXES, FIGPATH, FIGFILE) saves axes, HAXES, in a file 
% specified by FIGPATH and FIGFILE.

% for some reason, this fcn returns an error.. Seems that SAVEAS does not
% work after using COPYOBJ. This must be an known error.

% written by Taro Kiritani, tarokiritani2008@u.northwestern.edu, 1/14/2011
originalHandle = gcf;

figHandle = figure;
axesHandle = axes;
newAxs = copyobj(allchild(haxes),axesHandle);
saveas(gcf,[figfile,'.fig']);
% change the current object to the original object.
figure(originalHandle);